PROGRAM_NAME='Melton Master Bed'
(***********************************************************)
(***********************************************************)
(*  FILE_LAST_MODIFIED_ON: 04/05/2006  AT: 09:00:25        *)
(***********************************************************)
(* System Type : NetLinx                                   *)
(***********************************************************)
(* REV HISTORY:                                            *)
(***********************************************************)
(*
    $History: $
*)
#DEFINE DEBUG
(***********************************************************)
(*          DEVICE NUMBER DEFINITIONS GO BELOW             *)
(***********************************************************)
DEFINE_DEVICE
vdvTmEvents       = 33101:1:2
dvTmTimeSync      = 0:11:2

dvIPReporter      = 0:12:2

dvDebugLog        = 0:13:2
vdvDebugLog       = 33102:1:2

dvMBedDTV         = 0:16:2

dvIpad                = 11001:1:1
dvFamilyTP            = 11002:1:1
vdvKitchenKP          = 33402:1:1
vdvGarageKP           = 33403:1:1
dvMBedTP              = 11003:1:1
vdvMBathKP            = 33405:1:1

// Serial Devices
//dvMBedDTV = 5001:1:2
vdvMBedDTV = 33001:1:2

//IR Devices
dvMBedTV = 5001:8:2
vdvMBedTV = 33002:1:2

dvMBedDVD = 5001:10:2
vdvMBedDVD = 33003:1:2

dvMBedAVR = 5001:9:2
vdvMBedAVR = 33004:1:2

//Axlink Devices
dvMBedRemote = 88:1:2
vdvMBedRemote = 33103:1:2

vdvAudioSwitcher  = 33102:1:1

// Virtual Devices
vdvMBedAV = 33305:1:2

vdvInterRoomComms = 33300:1:1

vdvDummySwitcher = 33107:1:2
vdvDummyPanel    = 33108:1:2

(***********************************************************)
(*               CONSTANT DEFINITIONS GO BELOW             *)
(***********************************************************)
DEFINE_CONSTANT
cnMaxDebugLen = 200

//UI IDs
cnIpadID         = 1
cnFamilyTPID     = 2
cnKitchenKPID    = 3
cnGarageKPID     = 4
cnMBedTPID       = 5
cnMBathKPID      = 6
cnMaxUIs     = 6

cnMBedID = 5
cnMaxRooms = 6

// Source IDs
cnFamilyDtvID  = 1
cnFamilyDvdID  = 2
cnFamilyPs3ID  = 3
cnKitchenPCID  = 4
cnFamilyIpodID = 5
cnFamilyCdID   = 6
cnSatMusicID   = 7

cnMBedDTVID    = 8
cnMBedDVDID    = 9
cnMBedPS3ID    = 10

cnMaxSources = 10

(***********************************************************)
(*              DATA TYPE DEFINITIONS GO BELOW             *)
(***********************************************************)
DEFINE_TYPE

(***********************************************************)
(*               VARIABLE DEFINITIONS GO BELOW             *)
(***********************************************************)
DEFINE_VARIABLE
Volatile Char strClientName[] = 'Melton'
Volatile Char strDestinationEmail[] = 'russellmelton@sopris.net'
Volatile Char strJunk[10]

Volatile Char strMBedDTVIpAddress[] = '192.168.0.102'
Volatile Char strSatFavsFileName[] = 'SAT_FAVS.xml'

Volatile Dev daMBedPanels[cnMaxUIs]
Volatile Integer nMBedPanelSources[cnMaxUIs]

Volatile Dev daMBedDVDPanels[cnMaxUIs]
Volatile Dev daMBedDTVPanels[cnMaxUIs]

Volatile Integer nMBedRemoteButtonRemap[] = 
{
    30,   // 128- Off
    1010, // 129-  Source1 MBed Dtv
    1050, // 130-  Source2 MBed Dvd
    999,  // 131-  Source3 Unused
    999,  // 132-  Source4 Unused
    999,  // 133-  Source5 Unused
    999,  // 134-  Source6 Unused
    999,  // 135-  Source7 Unused
    999,  // 136-  Source8 Unused
    999,  // 137- Source9 Unused
    999,  // 138- Source10 Unused
    999,  // 139- Source11 Unused
    999,  // 140- Source12 Unused
    999,  // 141- Source13 Unused
    999,  // 142- Source14 Unused
    999,  // 143- Source15 Unused
    999,  // 144- Source16 Unused
    999,  // 145- Source17 Unused
    999,  // 146- Source18 Unused
    999,  // 147- Source19 Unused
    999,  // 148- Source20 Unused
    961,  // 149- Vol Up 
    962,  // 150- Vol Down
    963,  // 151- Mute Toggle
    228,  // 152- ChanUp
    229,  // 153- ChanDn
    251,  // 154- Up
    252,  // 155- Down
    253,  // 156- Left
    254,  // 157- Right
    255,  // 158- Select
    215,  // 159- Play
    216,  // 160- Stop
    217,  // 161- Pause
    218,  // 162- ScanFwd
    219,  // 163- ScanRev
    222,  // 164- Record
    38,   // 165-
    39,   // 166-
    200,  // 167- 0
    201,  // 168- 1
    202,  // 169- 2
    203,  // 170- 3
    204,  // 171- 4
    205,  // 172- 5
    206,  // 173- 6
    207,  // 174- 7
    208,  // 175- 8
    209,  // 176- 9
    211,  // 177- Dash
    213,  // 178- Enter
    237,  // 179- Jump
    243,  // 180- Back
    262,  // 181- Clear
    261,  // 182- Guide
    223,  // 183- Replay
    238,  // 184- Red
    239,  // 185- Green
    240,  // 186- Yellow
    241,  // 187- Blue
    227,  // 188- Advance
    260,  // 189- Menu
    269,  // 190- List
    265,  // 191- Display
    172,  // 192- Active
    66,   // 193-
    67,   // 194-
    68,   // 195-
    69,   // 196-
    70,   // 197-
    421,  // 198- Fav 1
    422,  // 199- Fav 2
    423,  // 200- Fav 3
    424,  // 201- Fav 4
    425,  // 202- Fav 5
    426,  // 203- Fav 6
    427,  // 204- Fav 7
    428,  // 205- Fav 8
    429,  // 206- Fav 9
    430,  // 207- Fav 10
    431,  // 208- Fav 11
    432,  // 209- Fav 12
    433,  // 210- Fav 13
    434,  // 211- Fav 14
    435,  // 212- Fav 15
    436,  // 213- Fav 16
    437,  // 214- Fav 17
    438,  // 215- Fav 18
    439,  // 216- Fav 19
    440,  // 217- Fav 20
    441,  // 218- Fav 21
    442,  // 219- Fav 22
    443,  // 220- Fav 23
    444,  // 221- Fav 24
    445,  // 222- Fav 25
    446,  // 223- Fav 26
    447,  // 224- Fav 27
    448,  // 225- Fav 28
    449,  // 226- Fav 29
    450,  // 227- Fav 30
    451,  // 228- Fav 31
    452,  // 229- Fav 32
    453,  // 230- Fav 33
    454,  // 231- Fav 34
    455,  // 232- Fav 35
    456,  // 233- Fav 36
    457,  // 234- Fav 37
    458,  // 235- Fav 38
    459,  // 236- Fav 39
    460,  // 237- Fav 40
    461,  // 238- Fav 41
    462,  // 239- Fav 42
    463,  // 240- Fav 43
    464,  // 241- Fav 44
    465,  // 242- Fav 45
    466,  // 243- Fav 46
    467,  // 244- Fav 47
    468,  // 245- Fav 48
    469,  // 246- Fav 49
    470   // 247- Fav 50
}

(***********************************************************)
(*               LATCHING DEFINITIONS GO BELOW             *)
(***********************************************************)
DEFINE_LATCHING

(***********************************************************)
(*       MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW           *)
(***********************************************************)
DEFINE_MUTUALLY_EXCLUSIVE

(***********************************************************)
(*        SUBROUTINE/FUNCTION DEFINITIONS GO BELOW         *)
(***********************************************************)
(* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *)
(* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *)
#Include 'i!-EquipmentMonitorOut.axi'
#Include 'Melton Common Include.axi'

Define_Call 'IPAD_PAGE_FLIPS' (Dev dvDevice, Integer nBtn, Integer nPanel)
{
    Stack_Var Integer nI
    Local_Var Char strSubSystemPage[30]
    
    Call 'DEBUG_OUTPUT' (__LINE__,"'Call IPAD_PAGE_FLIPS (',Itoa(dvDevice.Number),':',Itoa(dvDevice.Port),':',Itoa(dvDevice.System),', ',Itoa(nBtn),')'")
    strSubSystemPage = 'SOURCE Select Subsystem 02'
    Switch (nBtn)
    {
	Case 2: // Local DTV
	{
	    Call 'ADD_PANEL_TO_SOURCE' (dvDevice, daMBedDtvPanels)
	    Pulse[vdvMBedDtv,255] // rebuild events
	    Send_Command dvDevice,"'PAGE-VIDEO DirecTV DVR'"
	    Send_Command dvDevice,"'@PPN-VIDEO HDTV FAVORITES Page 1'"
	    Send_Command dvDevice,"'@PPN-',strSubSystemPage"
	}
	Case 3: // Local DVD
	{
	    Call 'ADD_PANEL_TO_SOURCE' (dvDevice, daMBedDvdPanels)
	    Pulse[vdvMBedDvd,1] // rebuild events
	    Send_Command dvDevice,"'PAGE-VIDEO Blu-ray Player'"
	    //Send_Command dvDevice,"'@PPN-VIDEO Blu-ray Networked'"
	    Send_Command dvDevice,"'@PPN-',strSubSystemPage"
	}
    }
}

Define_Call 'IPAD_DISCONNECT_SOURCE' (Dev dvPanel, Integer nButton)
{
    Switch (nButton)
    {
	Case 2: // Local DTV
	{
	    Call 'REMOVE_PANEL_FROM_SOURCE' (dvPanel, daMBedDtvPanels)
	    Pulse[vdvMBedDtv,255] // rebuild events
	}
	Case 3: // Local DVD
	{
	    Call 'REMOVE_PANEL_FROM_SOURCE' (dvPanel, daMBedDvdPanels)
	    Pulse[vdvMBedDvd,1] // rebuild events
	}
    }
}

(***********************************************************)
(*                STARTUP CODE GOES BELOW                  *)
(***********************************************************)
DEFINE_START

#INCLUDE 'Queue_and_Threshold_Sizes.axi'

SmtpSetServer('mail.paragonintranet.com')
SmtpSetUser('crestron+paragonintranet.com','Cr3str0n123')

sUI[cnMBedTPID].nZone = cnMBedID

daMBedPanels[1] = dvMBedTP

Set_Length_Array(daMBedPanels,1)
Wait 100
{
    Set_Length_Array(daMBedDtvPanels,0)
    Set_Length_Array(daMBedDvdPanels,0)

    // Format: SOURCE#=SourceValue,AudioInput,VideoInput,HDInput,AvrInput,TvInput,Name
    Send_Command vdvMBedAV,"'SOURCE1=',Itoa(sSourceInfo[cnMBedDtvID].nSourceValue),',',Itoa(sSourceInfo[cnMBedDtvID].nAudioInput),',',Itoa(sSourceInfo[cnMBedDtvID].nVideoInput),',',Itoa(sSourceInfo[cnMBedDtvID].nHDInput),',0,7,',sSourceInfo[cnMBedDtvID].strName"
    Send_Command vdvMBedAV,"'SOURCE2=',Itoa(sSourceInfo[cnMBedDvdID].nSourceValue),',',Itoa(sSourceInfo[cnMBedDvdID].nAudioInput),',',Itoa(sSourceInfo[cnMBedDvdID].nVideoInput),',',Itoa(sSourceInfo[cnMBedDvdID].nHDInput),',0,5,',sSourceInfo[cnMBedDvdID].strName"
    Send_Command vdvMBedAV,"'SOURCE3=',Itoa(sSourceInfo[cnMBedPs3ID].nSourceValue),',',Itoa(sSourceInfo[cnMBedPs3ID].nAudioInput),',',Itoa(sSourceInfo[cnMBedPs3ID].nVideoInput),',',Itoa(sSourceInfo[cnMBedPs3ID].nHDInput),',10,7,',sSourceInfo[cnFamilyPs3ID].strName"
    Send_Command vdvMBedAV,"'SOURCE5=',Itoa(sSourceInfo[cnFami
    lyIpodID].nSourceValue),',',Itoa(sSourceInfo[cnFamilyIpodID].nAudioInput),',',Itoa(sSourceInfo[cnFamilyIpodID].nVideoInput),',',Itoa(sSourceInfo[cnFamilyIpodID].nHDInput),',0,2,',sSourceInfo[cnFamilyIpodID].strName"
    Send_Command vdvMBedAV,"'SOURCE6=',Itoa(sSourceInfo[cnFamilyCdID].nSourceValue),',',Itoa(sSourceInfo[cnFamilyCdID].nAudioInput),',',Itoa(sSourceInfo[cnFamilyCdID].nVideoInput),',',Itoa(sSourceInfo[cnFamilyCdID].nHDInput),',0,2,',sSourceInfo[cnFamilyCdID].strName"
    Send_Command vdvMBedAV,"'SOURCE7=',Itoa(sSourceInfo[cnSatMusicID].nSourceValue),',',Itoa(sSourceInfo[cnSatMusicID].nAudioInput),',',Itoa(sSourceInfo[cnSatMusicID].nVideoInput),',',Itoa(sSourceInfo[cnSatMusicID].nHDInput),',0,2,',sSourceInfo[cnSatMusicID].strName"

    // Format: AVR=Off,VolUp,VolDown,MuteToggle,VolLevel,DirectVolInLevel,StartVol
    Send_Command vdvMBedAV,"'AVR=28,1,2,3'"
    Wait 50
    {
	Send_Command vdvInterRoomComms,"'REBUILD_EVENTS'"	
	Wait 50
	{
	    Send_Command vdvInterRoomComms,"'SWITCHROOM',Itoa(cnMBedID),'=0'" // turn off mbed for known starting point
	}
    }
}

(***********************************************************)
(*            MODULE DEFINITIONS GO BELOW                  *)
(***********************************************************)
Define_Module 'Debug Log' modDebugLog(dvDebugLog, vdvDebugLog, strClientName, strDestinationEmail)

Define_Module 'i!-TimeManagerMod' mdlTM(vdvTmEvents,
                                        dvTmTimeSync,
                                        (* Timezone *)
                                        dTmTzName,
                                        dTmTzDesc,
                                        dTmTzGmtOffset,
                                        strTmTzDstRules,
                                        (* Location *)
                                        strTmLocName,
                                        dTmLocLong,
                                        dTmLocLat,
                                        (* Timeserver *)
                                        nTmTsProtocol,
                                        nTmTsCheckTime,
                                        strTmTsServer)

Define_Module 'AS16 - Audio Video Zone' mdlMBed(vdvMBedAV, // Virtual Device For The Room
                                                    vdvInterRoomComms, // Inter Room Comm Virtual Device
						    daMBedPanels, // Room Panels
						    vdvAudioSwitcher, // Audio Switcher
						    vdvDummySwitcher, // Video Switcher
						    vdvDummySwitcher, // HD Switcher
						    vdvMBedAVR, // AVR
						    vdvMBedTV, // TV
						    sRoomInfo[cnMBedID].nAudioOutput, // Audio Output
						    sRoomInfo[cnMBedID].nVideoOutput, // Video Output
						    sRoomInfo[cnMBedID].nHDOutput, // HD Output
						    nRoomButtons, // Button Array
						    nRoomTextChans, // Text Channel Array
						    sRoomInfo[cnMBedID].nID, // Room ID
						    sRoomInfo[cnMBedID].strName) // Room Name

Define_Module 'IR TV' mdlMBedTV(dvMBedTV, vdvMBedTV)
Define_Module 'IR AVR' mdlMBedAVR(dvMBedAVR, vdvMBedAVR)

Define_Module 'IR DVD' mdlMBedDVD(dvMBedDVD, vdvMBedDVD, daMBedDVDPanels)

Define_Module 'DTV HR21 IP Driver' mdlMBedDTV(dvMBedDTV, vdvMBedDTV, strMBedDTVIpAddress)
Define_Module 'DTV Dynamic Preset Client' mdlMBedDTV_GUI(vdvMBedDTV,
						    daMBedDtvPanels,
						    nSatButtons,
						    nSatPresetButtons,
						    nSatPresetBmpChans,
						    nSatPresetTextChans,
						    nSatCurrentInfoChans,
						    strSatFavsFileName)

(***********************************************************)
(*                THE EVENTS GO BELOW                      *)
(***********************************************************)
DEFINE_EVENT
/*
Button_Event[dvMBedRemote,0] // any button press
{
    Push:
    {
	Do_Push_Timed(vdvMBedRemote,nMBedRemoteButtonRemap[Button.Input.Channel-127],Do_Push_Timed_Infinite)
    }
    Release:
    {
	Do_Release(vdvMBedRemote,nMBedRemoteButtonRemap[Button.Input.Channel-127])
    }
}
*/

Data_Event[vdvInterRoomComms]
{
    Command:
    {
	Local_Var Integer nSource, nAnyRoomOn, nI
	
	If (Find_String(Data.Text,'INUSE',1)) // Used for power management and in use indicator feedback
	{
	    strJunk = Remove_String(Data.Text,'INUSE',1)
	    nSource = Atoi(Data.Text)
	    If (nSource > 0 && nSource <= cnMaxSources)
	    {
		nAnyRoomOn = 0
		For (nI = 1; nI<= cnMaxRooms; nI++) // Loop through all rooms
		{
		    nAnyRoomOn = nAnyRoomOn + sRoomInfo[nI].nCurrentSource // Add every rooms source values together
		}
		If (nAnyRoomOn == 0) // If every room is off the result will be 0
		{
		    For (nI = 1; nI <= cnMaxSources; nI++) // since every room is off clear all in use values
		    {
			sSourceInfo[nI].nInUse = 0
		    }
		}
		
		If ( Find_String(Data.Text,'++',1))
		{
		    sSourceInfo[nSource].nInUse++
		    Send_Command vdvInterRoomComms,"'INUSE',Itoa(nSource),'=',Itoa(sSourceInfo[nSource].nInUse)"
		    If (sSourceInfo[nSource].nInUse == 1) // Turn Source On
		    {
			Switch (nSource)
			{
			    Case cnMBedDTVID:
			    {
				On[vdvMBedAV,61]
				Pulse[vdvMBedDTV,27]
			    }
			    Case cnMBedDVDID:
			    {
				On[vdvMBedAV,62]
				Wait 5
				    Call 'PULSE_IR' (dvMBedDVD, 1)
			    }
			    Case cnMBedPs3ID:
			    {
				On[daMBedPanels,63]
			    }
			}
		    }
		}
		Else If (Find_String(Data.Text,'--',1))
		{
		    sSourceInfo[nSource].nInUse = 0
		    For (nI = 1; nI <= cnMaxRooms; nI++)
		    {
			If (sRoomInfo[nI].nCurrentSource == nSource)
			{
			    sSourceInfo[nSource].nInUse++
			}
		    }
		    //If (sSourceInfo[nSource].nInUse > 0)
			//sSourceInfo[nSource].nInUse--
		    Send_Command vdvInterRoomComms,"'INUSE',Itoa(nSource),'=',Itoa(sSourceInfo[nSource].nInUse)"
		    
		    If (sSourceInfo[nSource].nInUse == 0) // Turn Source Off
		    {
			Switch (nSource)
			{
			    Case cnMBedDTVID:
			    {
				Off[daMBedPanels,61]
				Pulse[vdvMBedDTV,28]
			    }
			    Case cnMBedDVDID:
			    {
				Off[daMBedPanels,62]
				Wait 5
				    Call 'PULSE_IR' (dvMBedDVD, 28)
			    }
			    Case cnMBedPs3ID:
			    {
				Off[daMBedPanels,63]
			    }
			}
		    }
		}
	    }
	}
    }
}

Data_Event[dvMBedTV]
{
    Online:
    {
	Cancel_Wait 'MBED_NXI_IR_WAIT'
	Wait 15 'MBED_NXI_IR_WAIT'
	{
	    Send_Command dvMBedTV,"'SET MODE IR'"
	    Send_Command dvMBedTV,"'CARON'"
	    Send_Command dvMBedTV,"'CTON',3"
	    Send_Command dvMBedTV,"'CTOF',3"
	    Send_Command dvMBedTV,"'XCHM-3'"
	    Send_Command dvMBedTV,"'IROFF'"

	    Send_Command dvMBedAVR,"'SET MODE IR'"
	    Send_Command dvMBedAVR,"'CARON'"
	    Send_Command dvMBedAVR,"'CTON',3"
	    Send_Command dvMBedAVR,"'CTOF',3"
	    Send_Command dvMBedAVR,"'XCHM-3'"
	    Send_Command dvMBedAVR,"'IROFF'"

	    Send_Command dvMBedDVD,"'SET MODE IR'"
	    Send_Command dvMBedDVD,"'CARON'"
	    Send_Command dvMBedDVD,"'CTON',3"
	    Send_Command dvMBedDVD,"'CTOF',3"
	    Send_Command dvMBedDVD,"'XCHM-3'"
	    Send_Command dvMBedDVD,"'IROFF'"
	}
    }
}

// Begin Floating Panel
Button_Event[daAllUIs,nZoneListSelectButtons]
{
    Push:
    {
	Stack_var Integer nTPIndex
	
	nTPIndex = Get_Last(daAllUIs)
	
	Switch (sUI[nTPIndex].nZone)
	{
	    Case cnMBedID:
	    {
		Call 'REMOVE_PANEL_FROM_ZONE' (Button.Input.Device, daMBedPanels)
		Send_Command vdvMBedAV,"'REBUILD_EVENTS'"
	    }
	}
	Switch (sRoomInfo[sUI[nTPIndex].nZone].nCurrentSource)
	{
	    Case cnMBedDTVID: // Local DTV
	    {
		Call 'REMOVE_PANEL_FROM_SOURCE' (Button.Input.Device, daMBedDtvPanels)
		Pulse[vdvMBedDtv,255] // rebuild events
	    }
	    Case cnMBedDVDID: // Local DVD
	    {
		Call 'REMOVE_PANEL_FROM_SOURCE' (Button.Input.Device, daMBedDvdPanels)
		Pulse[vdvMBedDvd,1] // rebuild events
	    }
	}

	sUI[nTPIndex].nZone = Get_last(nZoneListSelectButtons) + sUI[nTPIndex].nZoneListPos
	Switch (sUI[nTPIndex].nZone)
	{
	    Case cnMBedID:
	    {
		Call 'ADD_PANEL_TO_ZONE' (Button.Input.Device, daMBedPanels)
		Send_Command vdvMBedAV,"'REBUILD_EVENTS'"
	    }
	}
	Switch (sRoomInfo[sUI[nTPIndex].nZone].nCurrentSource)
	{
	    Case cnMBedDTVID: // Local DTV
	    {
		Call 'ADD_PANEL_TO_SOURCE' (Button.Input.Device, daMBedDtvPanels)
		Pulse[vdvMBedDtv,255] // rebuild events
	    }
	    Case cnMBedDVDID: // Local DVD
	    {
		Call 'ADD_PANEL_TO_SOURCE' (Button.Input.Device, daMBedDvdPanels)
		Pulse[vdvMBedDvd,1] // rebuild events
	    }
	}
    }
}

Channel_Event[daAllIPads,nRoomButtons]
{
    On:
    {
	Stack_Var Integer nButton
	
	nButton = Get_last(nRoomButtons)
	Call 'DEBUG_OUTPUT' (__LINE__,"'On Get_last(nRoomButtons)=',Itoa(nButton)")
	If (nButton <= cnMaxSources + 1 && ![Channel.Device,nGlobalDisableConnectChan]) // make sure its a valid source and that we didnt just select something from global
	{
	    Send_Command Channel.Device,"'@PPX'"
	    Call 'IPAD_PAGE_FLIPS' (Channel.Device, nButton, Get_Last(daAllIpads))
	}
    }
    Off:
    {
	Stack_Var Integer nButton
	
	nButton = Get_Last(nRoomButtons)
	Call 'DEBUG_OUTPUT' (__LINE__,"'Off Get_last(nRoomButtons)=',Itoa(nButton)")
	If (nButton <= cnMaxSources + 1 && ![Channel.Device,nGlobalDisableConnectChan]) // make sure its a valid source and that we didnt just select something from global
	{
	    Call 'IPAD_DISCONNECT_SOURCE' (Channel.Device, nButton)
	}
    }
}

(***********************************************************)
(*            THE ACTUAL PROGRAM GOES BELOW                *)
(***********************************************************)
DEFINE_PROGRAM
//Wait 5
//    nMBedPanelSources[cnMBedRemote] = sRoomInfo[cnMBedID].nCurrentSource

(***********************************************************)
(*                     END OF PROGRAM                      *)
(*        DO NOT PUT ANY CODE BELOW THIS COMMENT           *)
(***********************************************************)

